/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mavenrentcars.validator.impl;

import com.mavenrentcars.form.CarForm;
import com.mavenrentcars.validator.Validator;

/**
 *
 * @author serg
 */
public class CarValidator extends GenericValidator implements Validator {

    public CarForm form;

    public CarValidator(CarForm form) {
        this.form = form;
    }

    @Override
    public boolean validation() {

        boolean res = true;
        if (form.action.equals("edit") && form.id.equals("")) {
            errors.put("id", "can not be empty");
            res = false;
        }

        if (form.action.equals("add") && form.model.equals("")) {
            errors.put("model", "can not be empty");
            res = false;
        }
        return res;
    }
}
